package brian.android.mvc.activity;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;

public abstract class AbstractListActivity extends AbstractActivity {
	@Override
	protected void initMembers() {
		super.initMembers();
		initList();
	}

	private void initList() {
		getListView().setAdapter(createListAdater());
		getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@SuppressWarnings("unchecked")
			@Override
			public void onItemClick(AdapterView parent, View view, int position, long id) {
				onListItemClick((ListView) parent, view, position, id);
			}
			
		});
	}

	protected abstract void onListItemClick(ListView parent, View view, int position, long id);
	
	protected abstract ListAdapter createListAdater();

	protected abstract ListView getListView();
	
}
